﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MindFactorial.Dynamic
{
	public class DynamicStateContext
    {
        Dictionary<string, object> _state = new Dictionary<string, object>();
        public void Store<T>(string name, T data)
        {
            if (_state.ContainsKey(name))
            {
                _state[name] = data;
            }
            else
            {
                _state.Add(name, data);
            }
        }

        public T Read<T>(string name)
        {
            if (_state.ContainsKey(name))
            {
                return (T)_state[name];
            }
            else
                return default(T);
        }
    }
}
